﻿/***********************************************************************
 * <copyright file="IRepository.cs" company="B/S JSC">
 * -->    Copyright (C) statement. All right reserved
 * </copyright>
 * 
 * Created:   Hoang Bich Son 
 * Email:    sonhb@newman.vn
 * Website:
 * Create Date: Friday, March 14, 2014
 * Usage: 
 * 
 * RevisionHistory: 
 * Date         Author               Description 
 * 
 * ************************************************************************/

using System.Collections.Generic;

namespace DxMvcApplication.Repositories.Core
{
    /// <summary>
    /// Generic repository base interface.
    /// Provides basic CRUD (Create, Read, Update, Delete) and a couple more methods.
    /// </summary>
    /// <typeparam name="T">The business object type.</typeparam>
    public interface IRepository<T>
    {

        /// <summary>
        /// Gets the size of the page.
        /// </summary>
        /// <returns></returns>
        int GetPageSize();

        /// <summary>
        /// Reads a list of items.
        /// </summary>
        /// <param name="criterion">The order and filter criteria.</param>
        /// <returns></returns>
        List<T> GetList(Criterion criterion = null);
       
        /// <summary>
        /// Gets the paged.
        /// </summary>
        /// <param name="totalPage">The total page.</param>
        /// <param name="currentPage">The current page.</param>
        /// <returns></returns>
        List<T> GetPaged(ref int totalPage, int currentPage=1);

        /// <summary>
        /// Reads an individual item.
        /// </summary>
        /// <param name="id">The business object's id.</param>
        /// <returns></returns>
        T Get(int id);                

        /// <summary>
        /// Inserts the specified t.
        /// </summary>
        /// <param name="t">The t.</param>
        /// <returns></returns>
        string Insert(T t);

        /// <summary>
        /// Updates an existing item.
        /// </summary>
        /// <param name="t">The business object.</param>
        string Update(T t);

        /// <summary>
        /// Deletes an item.
        /// </summary>
        /// <param name="idList">The identifier list.</param>
        /// <returns></returns>
        string Delete(IList<int> idList);        
    }
}